package com.demo.apparel.controller.uniapp;

import com.demo.apparel.common.Result;
import com.demo.apparel.dto.uniapp.ShopRegisterDTO;
import com.demo.apparel.entity.Shop;
import com.demo.apparel.service.uniapp.ShopService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/wx/shop")
@Tag(name = "商家入驻接口", description = "商家入驻信息接口")
public class WxShopController {

    @Autowired
    private ShopService shopService;

    // 用户申请入驻
    @PostMapping("/register")
    public Result<String> register(@RequestBody ShopRegisterDTO dto,
                                   @RequestAttribute("userId") String userId) {
        shopService.registerShop(dto, userId);
        return Result.success("商家入驻成功！");
    }

    // 根据用户查询商家信息
    @GetMapping("/my")
    public Result<Shop> getMyShop(@RequestAttribute("userId") String userId) {
        Shop shop = shopService.getShopByUserId(userId);
        return Result.success(shop);
    }
}
